package cn.ylg.com.baisibudeijie.lib.callback;

import java.lang.reflect.ParameterizedType;

public abstract class ObjectCallback<T> {

	private final Class<T> clazz;

	@SuppressWarnings("unchecked")
	public ObjectCallback() {
		//将对象转化为类;
		ParameterizedType type = (ParameterizedType) this.getClass()
				.getGenericSuperclass();//获得泛型的clazz类型
		clazz = (Class<T>) type.getActualTypeArguments()[0];
	}

	public Class<T> getDataClass() {
		return clazz;
	}

	public abstract void onSuccess(T data);

	public abstract void onFailure(int errorCode, String errorString);
}
